using Business.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;

namespace Business.Permissions
{
    public class BusinessPermissionDefinitionProvider: PermissionDefinitionProvider
    {

        public override void Define(IPermissionDefinitionContext context)
        {
            var Business = context.AddGroup(BusinessPermissions.Business, L("Business"), MultiTenancySides.Tenant);

            var Book = Business.AddPermission(BusinessPermissions.Book.Default, L("Book"));
            Book.AddChild(BusinessPermissions.Book.Update, L("Edit"));
            Book.AddChild(BusinessPermissions.Book.Delete, L("Delete"));
            Book.AddChild(BusinessPermissions.Book.Create, L("Create"));

            var PrintTemplate = Business.AddPermission(BusinessPermissions.PrintTemplate.Default, L("PrintTemplate"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Update, L("Edit"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Delete, L("Delete"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Create, L("Create"));

            // More code generation...
            var Warehouse = Business.AddPermission(BusinessPermissions.Warehouse.Default, L("Warehouse"));
            Warehouse.AddChild(BusinessPermissions.Warehouse.Update, L("Edit"));
            Warehouse.AddChild(BusinessPermissions.Warehouse.Delete, L("Delete"));
            Warehouse.AddChild(BusinessPermissions.Warehouse.Create, L("Create"));

            var WarehouseArea = Business.AddPermission(BusinessPermissions.WarehouseArea.Default, L("WarehouseArea"));
            WarehouseArea.AddChild(BusinessPermissions.WarehouseArea.Update, L("Edit"));
            WarehouseArea.AddChild(BusinessPermissions.WarehouseArea.Delete, L("Delete"));
            WarehouseArea.AddChild(BusinessPermissions.WarehouseArea.Create, L("Create"));

            var Area = Business.AddPermission(BusinessPermissions.Area.Default, L("Area"));
            Area.AddChild(BusinessPermissions.Area.Update, L("Edit"));
            Area.AddChild(BusinessPermissions.Area.Delete, L("Delete"));
            Area.AddChild(BusinessPermissions.Area.Create, L("Create"));

            var WarehouseLocation = Business.AddPermission(BusinessPermissions.WarehouseLocation.Default, L("WarehouseLocation"));
            WarehouseLocation.AddChild(BusinessPermissions.WarehouseLocation.Update, L("Edit"));
            WarehouseLocation.AddChild(BusinessPermissions.WarehouseLocation.Delete, L("Delete"));
            WarehouseLocation.AddChild(BusinessPermissions.WarehouseLocation.Create, L("Create"));

            //Code generation...



        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<BusinessResource>(name);
        }
    }
}
